package com.fjnldx.mes.controller.schedulingClasses;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjnldx.mes.domain.domainReq.PageRequest;
import com.fjnldx.mes.domain.domainRes.Result;
import com.fjnldx.mes.domain.pojo.SchedulingClasses;
import com.fjnldx.mes.service.schedulingClasses.SchedulingClassesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/scheduling/classes")
@Api(value = "班次管理", tags = "班次管理")
public class SchedulingClassesController {

    @Resource
    private SchedulingClassesService schedulingClassesService;

    @PostMapping("/addClasses")
    @ApiOperation(value = "新增班次(单个)", notes = "新增班次(单个)")
    public Result addClasses(@RequestBody SchedulingClasses schedulingClasses){
        return schedulingClassesService.addClasses(schedulingClasses);
    }

    @DeleteMapping("/deleteClasses")
    @ApiOperation(value = "删除班次", notes = "删除班次")
    public Result deleteClasses(@RequestParam ArrayList<Integer> ids){
        return schedulingClassesService.deleteClasses(ids);
    }

    @PostMapping("/modifyClasses")
    @ApiOperation(value = "修改班次", notes = "修改班次")
    public Result modifyClasses(SchedulingClasses schedulingClasses){
        return schedulingClassesService.modifyClasses(schedulingClasses);
    }

    @GetMapping("/queryClasses")
    @ApiOperation(value = "查询班次", notes = "查询班次")
    public Result queryClasses(SchedulingClasses schedulingClasses, PageRequest pageRequest){

        Page page = new Page();
        page.setSize(pageRequest.getPageSize());
        page.setCurrent(pageRequest.getPageNum());
        return Result.success(schedulingClassesService.queryClasses(schedulingClasses, page));
    }
}
